import { App } from 'vue';
import { withInstall } from '@ibiz-template/vue3-util';
import { registerToolbarItemProvider } from '@ibiz-template/runtime';
import { ToolbarItemPlugin } from './toolbar-item';
import { ToolbarItemPluginProvider } from './toolbar-item-provider';

export const IBizToolbarItemPlugin = withInstall(
  ToolbarItemPlugin,
  function (v: App) {
    // 全局注册工具栏项插件组件
    v.component(ToolbarItemPlugin.name, ToolbarItemPlugin);
    // 全局注册工具栏项适配器，TOOLBAR_ITEM是插件类型，R9ToolbarItemPluginId是插件标识
    registerToolbarItemProvider(
      'TOOLBAR_ITEM_R9ToolbarItemPluginId',
      () => new ToolbarItemPluginProvider(),
    );
  },
);

export default IBizToolbarItemPlugin;
